//
//  lyjViewController.m
//  LYJDateService
//
//  Created by li625317534 on 03/28/2017.
//  Copyright (c) 2017 li625317534. All rights reserved.
//

#import "lyjViewController.h"
#import <LYJDateService/LYJDateService-umbrella.h>

@interface lyjViewController ()

@end

@implementation lyjViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    [self LYJDateServiceTest];
}


/**
 LYJDateService demo 测试
 */
- (void)LYJDateServiceTest {
    
    // 注意: 输入的时间格式 TimeString 必须与后面的时间格式表达式 timeFormatter 保持一致,不然会报错
    NSTimeInterval timeInterval = [LYJDateService timeStringToTimestampWithTimeString:@"2017/10/25 13:30:30:288" timeFormatter:@"yyyy/MM/dd HH:mm:ss:SSS"];
    NSLog(@"TimeInterval is %.3f" , timeInterval); // 结果: imeInterval is 1508909430.288
    
    NSString *timeString = [LYJDateService timestampToDateStringWithTimeStamp:timeInterval timeFormatter:@"yyyy年MM月dd日 HH时:mm分:ss秒.SSS毫秒"];
    NSLog(@"timeString is %@" , timeString); // 结果: timeString is 2017年10月25日 13时:30分:30秒.288毫秒
    
    NSTimeInterval todayTimeInterval = [LYJDateService getOneDayTimestampFromTodayWithDayNumber:0];
    NSLog(@"todayTimeInterval is %.f" , todayTimeInterval); // 结果: todayTimeInterval is 1490671288
    NSLog(@"today is %@" , [LYJDateService timestampToDateStringWithTimeStamp:todayTimeInterval timeFormatter:@"yyyy年MM月dd日"]); // 结果: today is 2017年03月28日
    
    NSTimeInterval tomorrowTimeInterval = [LYJDateService getOneDayTimestampFromTodayWithDayNumber:1];
    NSLog(@"tomorrowTimeInterval is %.f" , tomorrowTimeInterval); // 结果: tomorrowTimeInterval is 1490757688
    NSLog(@"tomorrow is %@" , [LYJDateService timestampToDateStringWithTimeStamp:tomorrowTimeInterval timeFormatter:@"yyyy年MM月dd日"]); // 结果: tomorrow is 2017年03月29日
    
    NSTimeInterval yesterdayTimeInterval = [LYJDateService getOneDayTimestampFromTodayWithDayNumber:-1];
    NSLog(@"yesterdayTimeInterval is %.f" , yesterdayTimeInterval); // 结果: yesterdayTimeInterval is 1490585331
    NSLog(@"yestoday is %@" , [LYJDateService timestampToDateStringWithTimeStamp:yesterdayTimeInterval timeFormatter:@"yyyy年MM月dd日"]); // 结果: yestoday is 2017年03月27日
    
    NSTimeInterval todayTimeIntervalCurrent = [LYJDateService getOneDayTimestampFromTodayWithDayNumber:0 delayHourTime:0];
    NSLog(@"todayTimeIntervalCurrent is %.f , date is %@" , todayTimeIntervalCurrent , [LYJDateService timestampToDateStringWithTimeStamp:todayTimeIntervalCurrent timeFormatter:@"yyyy/MM/dd HH:mm:ss"]); // 结果: todayTimeIntervalCurrent is 1490673096 , date is 2017/03/28 11:51:36
    NSTimeInterval todayTimeIntervalDelayOneHour = [LYJDateService getOneDayTimestampFromTodayWithDayNumber:0 delayHourTime:1];
    NSLog(@"todayTimeIntervalDelayOneHour is %.f , date is %@" , todayTimeIntervalCurrent , [LYJDateService timestampToDateStringWithTimeStamp:todayTimeIntervalDelayOneHour timeFormatter:@"yyyy/MM/dd HH:mm:ss"]); // 结果: todayTimeIntervalDelayOneHour is 1490673096 , date is 2017/03/28 12:51:36
    
    NSString *weekString = [LYJDateService getOneDayWeekFromTodayWithDayNumber:0 weekArray:nil];
    NSLog(@"weekString is %@" , weekString); // 结果: weekString is 周二
    
    NSString *weekStringTimestamp = [LYJDateService getOneDayWeekFromOnedayTimestamp:tomorrowTimeInterval dayNumber:0 weekArray:@[@"星期日" , @"星期一" , @"星期二" , @"星期三" , @"星期四" , @"星期五" , @"星期六" , @"星期日"]];
    NSLog(@"weekStringTimestamp is %@" , weekStringTimestamp); // 结果: weekStringTimestamp is 星期三
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
